package com.gongzonqiang.pojo;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.gongzonqiang.myenum.UserEnum;

import lombok.Data;

@Data
@Table(name = "`user`")
public class User {
	@Id
	@Column(name = "`openId`")
	private String openid;

	@Column(name = "`nickname`")
	private String nickname;

	@Column(name = "`password`")
	private String password;

	@Column(name = "`headImg`")
	private String headimg;

	@Column(name = "`phone`")
	private String phone;

	/**
	 * 0拉黑(禁止登陆) 1正常 2管理员
	 */
	@Column(name = "`status`")
	private Integer status;

	@Transient
	private String statusStr;

	@Column(name = "`create_date`", insertable = false)
	private Date createDate;

	@Column(name = "`update_date`", updatable = false)
	private Date updateDate;

	/**
	 * @return openId
	 */
	public String getOpenid() {
		return openid;
	}

	/**
	 * @param openid
	 */
	public void setOpenid(String openid) {
		this.openid = openid;
	}

	/**
	 * @return nickname
	 */
	public String getNickname() {
		return nickname;
	}

	/**
	 * @param nickname
	 */
	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return headImg
	 */
	public String getHeadimg() {
		return headimg;
	}

	/**
	 * @param headimg
	 */
	public void setHeadimg(String headimg) {
		this.headimg = headimg;
	}

	/**
	 * @return phone
	 */
	public String getPhone() {
		return phone;
	}

	/**
	 * @param phone
	 */
	public void setPhone(String phone) {
		this.phone = phone;
	}

	/**
	 * 获取0拉黑(禁止登陆) 1正常 2管理员
	 *
	 * @return status - 0拉黑(禁止登陆) 1正常 2管理员
	 */
	public Integer getStatus() {
		return status;
	}

	/**
	 * 设置0拉黑(禁止登陆) 1正常 2管理员
	 *
	 * @param status 0拉黑(禁止登陆) 1正常 2管理员
	 */
	public void setStatus(Integer status) {
		this.status = status;
	}

	/**
	 * @return create_date
	 */
	public Date getCreateDate() {
		return createDate;
	}

	/**
	 * @param createDate
	 */
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	/**
	 * @return update_date
	 */
	public Date getUpdateDate() {
		return updateDate;
	}

	/**
	 * @param updateDate
	 */
	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	@Override
	public String toString() {
		return "User [openid=" + openid + ", nickname=" + nickname + "]";
	}

	public String getStatusStr() {
		UserEnum[] values = UserEnum.values();
		for (UserEnum e : values) {
			if (e.getCode() == this.status) {
				return e.getMessage();
			}
		}
		return null;
	}
	public void setStatusStr(String StatusStr) {
		this.statusStr = StatusStr;
	}
}